package org.nighthawkhosting.SC2Mapster;

import java.util.ArrayList;
import java.util.Date;

import org.apache.http.cookie.Cookie;
import org.apache.http.impl.cookie.BasicClientCookie;

public class CookieParser {
	
	public static ArrayList<String> parse(Cookie data) {
		BasicClientCookie tempData = (BasicClientCookie) data;
		ArrayList<String> returnData = new ArrayList<String>();
		
		returnData.add(tempData.getName());
		returnData.add(tempData.getValue());
		returnData.add(tempData.getComment());
		returnData.add(tempData.getDomain());
		returnData.add(tempData.getPath());
		returnData.add(String.valueOf(tempData.getVersion()));
		returnData.add(String.valueOf(tempData.getExpiryDate().getTime()));
		
		return returnData;
	}
	
	public static Cookie parse(ArrayList<String> data) {
		BasicClientCookie returnData= new BasicClientCookie(data.get(0), data.get(1));
		
		returnData.setComment(data.get(2));
		returnData.setDomain(data.get(3));
		returnData.setPath(data.get(4));
		returnData.setVersion(Integer.valueOf(data.get(5)));
		returnData.setExpiryDate(new Date(Long.valueOf(data.get(6))));
		return returnData;
	}
}
